gh-155286: Write a valid empty zstd archive - #155342
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 75d82ce9a2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| self._mode = _MODE_WRITE | ||
| # Do not add an empty frame when closing an existing archive in | ||
| # append mode without writing anything. | ||
| self._write_started = mode == 'a' |
There was a problem hiding this comment.
Emit a frame for newly created append targets
When ZstdFile(path, "a") creates a nonexistent file, or opens an existing zero-byte file, setting _write_started solely from the mode makes close() short-circuit because a new compressor's last_mode is already FLUSH_FRAME. With no writes, the target therefore remains a zero-byte, invalid Zstandard archive—the same failure this change fixes for w and x. Preserve no-op behavior only when the append target already contains archive data.
Useful? React with 👍 / 👎.
Fixes #155286.
Summary:
Tests: